﻿using BaseUI;
using BLL;
using Model;
using System;

namespace Thksoft.Module.ParameterSettings
{
    public partial class AnnouncementDetail : BasePage
    {
        private SYS_ANNOUNCEMENTBLL amentBLL = new SYS_ANNOUNCEMENTBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["ID"]))
                {
                    string id = Request.QueryString["ID"].ToString();

                    SYS_ANNOUNCEMENT model = amentBLL.SelectById(id);

                    if (model != null)
                    {
                        txtUserName.Text = new Sys_UserBLL().GetUserNameS(model.N_USERID.ToString());
                        txtStartTime.Text = model.D_STARTTIME.ToString("yyyy-MM-dd HH:mm:ss");
                        txtName.Text = model.C_NAME.ToString();
                        txtContent.Value = model.C_CONTENT.ToString();
                    }
                }
            }
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            MessageBox.ResponseScript(this, "FORM_CLOSE();");
        }

        /// <summary>
        /// 发布公告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnFabu_Click(object sender, EventArgs e)
        {
            string id = Request.QueryString["ID"].ToString();
            SYS_ANNOUNCEMENT model = amentBLL.SelectById(id);

            if (model.D_ENDTIME < DateTime.Now || model.N_STATE == 0)
            {
                MessageBox.Show(Page, "抱歉，当前公告已过期或状态无效，不能发布！");
                return;
            }
        }
    }
}